package com.codegeek.project.slope.controller;

import com.codegeek.common.utils.poi.ExcelUtil;
import com.codegeek.framework.aspectj.lang.annotation.Log;
import com.codegeek.framework.aspectj.lang.enums.BusinessType;
import com.codegeek.framework.web.controller.BaseController;
import com.codegeek.framework.web.domain.AjaxResult;
import com.codegeek.framework.web.page.TableDataInfo;
import com.codegeek.project.slope.domain.SlopeHistoryVideo;
import com.codegeek.project.slope.service.ISlopeHistoryVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 历史视频Controller
 *
 * @author codegeek
 * @date 2020-02-17
 */
@RestController
@RequestMapping("/slope/video")
@Api(value = "历史视频Controller", tags = {"历史视频操作接口"})
public class SlopeHistoryVideoController extends BaseController {
    @Autowired
    private ISlopeHistoryVideoService slopeHistoryVideoService;

    /**
     * 查询历史视频列表
     */
    @ApiOperation("查询历史视频列表")
    @GetMapping("/list")
    public TableDataInfo list(SlopeHistoryVideo slopeHistoryVideo) {
        startPage();
        List<SlopeHistoryVideo> list = slopeHistoryVideoService.selectSlopeHistoryVideoList(slopeHistoryVideo);
        return getDataTable(list);
    }

    /**
     * 导出历史视频列表
     */
    @ApiOperation("导出历史视频列表")
    @Log(title = "监测管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SlopeHistoryVideo slopeHistoryVideo) {
        List<SlopeHistoryVideo> list = slopeHistoryVideoService.selectSlopeHistoryVideoList(slopeHistoryVideo);
        ExcelUtil<SlopeHistoryVideo> util = new ExcelUtil<SlopeHistoryVideo>(SlopeHistoryVideo.class);
        return util.exportExcel(list, "video");
    }

    /**
     * 获取历史视频详细信息
     */
    @ApiOperation("获取历史视频详细信息")
    @GetMapping(value = "/getInfo/{historyVideoId}")
    public AjaxResult getInfo(@PathVariable("historyVideoId") Long historyVideoId) {
        return AjaxResult.success(slopeHistoryVideoService.selectSlopeHistoryVideoById(historyVideoId));
    }

    /**
     * 新增历史视频
     */
    @ApiOperation("新增历史视频")
    @Log(title = "监测管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SlopeHistoryVideo slopeHistoryVideo) {
        return toAjax(slopeHistoryVideoService.insertSlopeHistoryVideo(slopeHistoryVideo));
    }

    /**
     * 修改历史视频
     */
    @ApiOperation("修改历史视频")
    @Log(title = "监测管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SlopeHistoryVideo slopeHistoryVideo) {
        return toAjax(slopeHistoryVideoService.updateSlopeHistoryVideo(slopeHistoryVideo));
    }

    /**
     * 删除历史视频
     */
    @ApiOperation("删除历史视频")
    @Log(title = "监测管理", businessType = BusinessType.DELETE)
    @PostMapping("/remove/{historyVideoIds}")
    public AjaxResult remove(@PathVariable Long[] historyVideoIds) {
        return toAjax(slopeHistoryVideoService.deleteSlopeHistoryVideoByIds(historyVideoIds));
    }
}
